package xyz.chaobei.plugin;

import org.apache.ibatis.executor.Executor;
import org.apache.ibatis.mapping.MappedStatement;
import org.apache.ibatis.plugin.*;

import java.util.Properties;

/**
 * @description: 简单拦截器
 * @author: <a href='mailto:maruichao52@gmail.com'>MRC</a>
 * @since 2022/2/10
 **/
@Intercepts({@Signature(
        type = Executor.class,
        method = "update",
        args = {MappedStatement.class, Object.class})})
public class SimplePlugin implements Interceptor {

    private Properties properties;

    public Object intercept(Invocation invocation) throws Throwable {

        Object result = invocation.proceed();
        System.out.println("执行结果=" + result);

        return result;
    }

    public Object plugin(Object target) {
        return Plugin.wrap(target, this);
    }

    public void setProperties(Properties properties) {
        this.properties = properties;
    }
}
